package com.woniuxy.controller;


import com.woniuxy.entity.WardManage;
import com.woniuxy.service.WardManagerService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ward")
public class WardManagerController {


    @Resource
    private WardManagerService wardManagerService;


    @GetMapping("/queryTde")
    public ResponseData<?> queryTde(){
        return wardManagerService.queryTde();
    }

    @PostMapping("/queryWard")
    public ResponseData<?> queryList(@RequestBody PageParam<WardManage> pageParam){
        Assert.notNull(pageParam,"pageParam is not null");
        return wardManagerService.queryWard(pageParam);
    }

    @PostMapping("/addWard")
    public ResponseData<?> addWard(@RequestBody WardManage wardManage){
        Assert.notNull(wardManage,"wardManage is not null");
        return wardManagerService.addWard(wardManage);
    }


    //根据id查询病房
    @GetMapping("/queryWardById/{id}")
    public ResponseData<?> queryWardById(@PathVariable("id")Integer id){
        return wardManagerService.queryWardById(id);
    }

    //修改病房
    @PostMapping("/updateWard")
    public ResponseData<?> updateWard(@RequestBody WardManage wardManage){
        Assert.notNull(wardManage,"wardManage is not null");
        return wardManagerService.updateWard(wardManage);
    }

    //删除病房
    @GetMapping("/deleteWard/{id}")
    public ResponseData<?> deleteWard(@PathVariable("id")Integer id){
        Assert.notNull(id,"id is not null");
        return wardManagerService.deleteWard(id);
    }
}
